﻿<style>
    .useritem {
    }

    #project-stat .layui-table-header {
        display: block !important;
    }
</style>
<div id="project-stat">
    <div class="layui-progress layui-progress-big" lay-showPercent="yes">
        <div class="layui-progress-bar layui-bg-green progress-rate" style="width: 0%;">
                <span class="layui-progress-text"><span style="margin-left: 5px;"
                                                        class="progress-rate-value">0%</span></span>
        </div>
    </div>
    <div>
        <input type="text" class="layui-input" id="time"
               name="time"
               placeholder="yyyy-MM-dd" value="">
        <table lay-filter="parse-table-error">
            <thead>
            <tr>
                <th lay-data="{field:'name',width:100}">姓名</th>
                <th lay-data="{field:'taskall',width:100}">任务数</th>
                <th lay-data="{field:'taskdone'}">完成数</th>
                <th lay-data="{field:'days'}">应发日报</th>
                <th lay-data="{field:'daily'}">已发日报</th>
                <th lay-data="{field:'weekly'}">周报次数</th>
            </tr>
            </thead>
            <tbody id="errortable-id">
            </tbody>
        </table>
    </div>
</div>
<script type="text/javascript">
    var table;
    layui.define(['layer', 'form', 'laydate', 'table'], function (exports) {
        var form = layui.form;
        var laydate = layui.laydate;
        table = layui.table;
        form.render("select"); //这个很重要
        var id = workUtils.get("id");
        $.getJSON("../project/getstat/" + id, function (data) {
            $(".progress-rate").css("width", data.l3 + "%");
            $(".progress-rate-value").text(data.l3 + "%");
        });

        //常规用法
        laydate.render({
            elem: '#time',
            type: 'date',
            format: 'yyyy-MM-dd',
            value: workUtils.getNowDate(),
            done: function (value, date, endDate) {
                loadReportStat();
            }
        });

        loadReportStat();
    });

    function loadReportStat() {
        workUtils.ajaxGet("../report/stat", {
            projectId: workUtils.get("id"),
            time: $("#time").val()
        }, function (data) {
            var html = '';
            for (var i in data) {
                var item = data[i];
                html += '<tr>';
                html += '<td>' + item.name + '</td>';
                html += '<td>' + item.taskall + '</td>';
                html += '<td>' + item.taskdone + '</td>';
                html += '<td>' + item.days + '</td>';
                html += '<td>' + item.daily + '</td>';
                html += '<td>' + item.weekly + '</td>';
                html += '</tr>';
            }
            $("#errortable-id").html(html);
            table.init('parse-table-error', {
                height: 'full-315',
                width: '99%'
            });
        });
    }

</script>